<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>Document</title>
	</head>

	<body>
		<script src="./lib/vue-2.6.10/dist/vue.min.js"></script>
		<!-- vue实例所控制的这个元素区域，就是我们的 v -->
		<div id="app">
      <div>
        <span>id:</span><input type="text" v-model="id">
        <span>name:</span><input type="text" v-model="name">
        <input type="button" value="add" @click="add">

      </div>
      <!-- key: number || string -->
      <p v-for="(item, i) in list" :key="item.id">
        <input type="checkbox">
        <span>{{item.id}}-{{item.name}}</span>
      </p>
		

		</div>

		<script>
			var vm = new Vue({
				el: "#app",
				data: {
          id: '',
          name: '',
          list: [
            { id: 1, name: '李斯'},
            { id: 2, name: '嬴政'},
            { id: 3, name: '赵高'},
            { id: 4, name: '韩非'},
            { id: 5, name: '荀子'},
          ]

				},
				methods: {
          add() {
            this.list.unshift({id: this.id, name: this.name})

          }
				}
			});
		</script>
	</body>
</html>
